package com.zhny.aiot.rtu.no.dir.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.modbus.ModemServer;
import com.zhny.aiot.plugin.modbus.device.ModemConfig;
import com.zhny.aiot.plugin.modbus.device.ModemDeviceFactory;
import com.zhny.aiot.plugin.modbus.handler.model.ModemRequestMessage;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.rtu.no.dir.plugin.model.RTUNODIRStoreEntry;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.ArrayList;
import java.util.List;

public class RTUNODIRPlugin extends Plugin {
    public RTUNODIRPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class RollFilmFactory extends ModemDeviceFactory<RTUNODIRStoreEntry> {

        public ModemRequestMessage getRequestMessage(ModemConfig modemConfig) {
            return null;
        }

        @Override
        public List<CommandEntry> supportCommandClasses(){
            List<CommandEntry> commands = new ArrayList<> ();
            commands.add(CommandEntry.valueOf("open", "打开", "无参数",null));
            commands.add(CommandEntry.valueOf("close", "关闭", "无参数",null));
            commands.add(CommandEntry.valueOf("query", "检测", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new RTUNODIRDevice (ModemServer.getInstance ().getEngine () ,this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return RTUNODIRStoreEntry.class;
        }

        public String getId() {
            return "zhny-rtu-no-dir-plugin";
        }

        public String getName() {
            return "RTU-NO-DIR设备插件";
        }

        public FactoryType getType() {
            return FactoryType.OpenCloseController;
        }
    }
}
